<template>
<div class="pulpInfo">
    <el-row v-if="basicInfo">
        <el-col :span="16">
            <el-form :inline="true" :model="basicInfo" label-width="100px" class="demo-ruleForm">
                <el-form-item class="inputNoMb" label="卡号"><el-input v-model="basicInfo.id" disabled ></el-input></el-form-item>
                <el-form-item class="inputNoMb" label="姓名"><el-input v-model="basicInfo.name" disabled></el-input></el-form-item>
                <el-form-item class="inputNoMb" label="年龄"><el-input v-model="basicInfo.age" disabled></el-input></el-form-item>
                <el-form-item class="inputNoMb" label="性别"><el-input v-model="basicInfo.sexName" disabled></el-input></el-form-item>
                <el-form-item class="inputNoMb" label="身份证号"><el-input v-model="basicInfo.idNo" disabled></el-input></el-form-item>
                <el-form-item class="inputNoMb" label="电话"><el-input v-model="basicInfo.phone" disabled></el-input></el-form-item>
                <el-form-item class="inputNoMb" label="地址"><el-input v-model="basicInfo.address" disabled></el-input></el-form-item>
            </el-form>
        </el-col>
        <el-col :span="8" target="div"  class="pulpWorkImg">
            <img :src="basicInfo.photo"  :onerror="defaultImg"/>
        </el-col>
    </el-row>
</div>
</template>
<script>
import api from '@/axios/api.js';
import default1 from 'static/img/default1.jpg';
import default2 from 'static/img/default2.jpg';
export default {
 name: "pulpworkInfo",
 props:['cardid'],
 data(){
     return{
         defaultImg:'',
         basicInfo:{},
         sexObj:[]
     }
 },
 created(){
    let self = this;
    api.getCodeData(7).then(res=>{
        self.sexObj=res.content;
    });
    self.getBasicInfo(self.cardid);
 },
 watch:{
     cardid(newCardid,oldCardid){
         this.basicInfo={};
         this.getBasicInfo(newCardid);
     }
 },
 methods:{
     getBasicInfo(cardid){
        let self = this;
        api.basicInfo({cardid}).then(res=>{
            self.basicInfo= res.content;
            self.sexObj.forEach(sexItem=>{
                if(self.basicInfo.sex==sexItem.code){
                    self.basicInfo.sexName=sexItem.name;
                }
            })
            if(self.basicInfo.sexName.indexOf('女')>-1){
                    self.defaultImg=`this.src="${default2}"`;
            }else{
                self.defaultImg=`this.src="${default1}"`;
            }
        });
    }
 }
}
</script>
<style scoped>

.pulpInfo .pulpWorkImg{
    text-align: center;

}
.pulpInfo .pulpWorkImg>img{
     width:200px;
}
</style>

